package com.zkdcloud.repository;

import com.zkdcloud.domain.Favorite;
import org.jfaster.mango.annotation.DB;
import org.jfaster.mango.annotation.SQL;
import org.jfaster.mango.plugin.page.Page;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zk123
 * @version 2018/5/24
 */
@DB(table = "favorite")
@Repository
public interface FavoriteDao {
    String COLUMNS = "id,user_id,business_id,create_time";

    /**
     * 添加喜欢
     *
     * @param favorite favorite
     */
    @SQL("insert into #table("+COLUMNS+")values(:id,:userId,:businessId,:createTime)")
    void add(Favorite favorite);

    /**
     * 根据uid筛选
     *
     * @param uid uid
     * @return list
     */
    @SQL("select * from #table where user_id = :1")
    List<Favorite> getAllByUid(String uid, Page page);

    /**
     * 根据uid和bid获取
     *
     * @param bid bid
     * @param uid uid
     * @return fa
     */
    @SQL("select * from #table where business_id = :1 and user_id = :2")
    Favorite getByUidAndBid(String bid ,String uid);

    /**
     * 根据id删除
     *
     * @param id id
     */
    @SQL("delete from #table where id = :1")
    void removeById(String id);
}
